   /*the default options for jquery.form plugin */
   var options = {
        beforeSubmit:  ShowLoader,  // pre-submit callback
        success:       showResponse,  // post-submit callback
        dataType:   "json"        // 'xml', 'script', or 'json' (expected server response type)
    };


	function showResponse(data, statusText, xhr, $form){
	   if(data.success){
       	}
      
	   if(data.error){
		   alert(data.error);
	   }
	   if(data.refresh){
	      location.reload(true);
	   }
	   if(data.redirect)	{
		   window.location = data.redirect;
	   }
	}

  function ShowLoader()
   {
     //$("#message").hide();
     var h=$(window).height();
     var w=$(window).width();
     $("#loader").css({height:10, opacity: 0.5});
     $("#loaderimg").css({"margin-left": h/2-50});
     $("#loaderimg").css({"width": w});
     //$("#loaderimg").css({"bottom": h/2-500});
     $("#loader").show();
     //$('input[type=submit]').attr('disabled', 'disabled');
	 $("body").css("cursor", "progress");
	 
   }
  function HideLoader()
   {
     $("#loader").hide();
     $("body").css("cursor", "auto");
   }

   /* Submit a form, ajax post method */
   function Send(id_form){
       $(id_form).ajaxSubmit(options);
	   return false;
   }